<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: f
  Date: 2020/10/7
  Time: 8:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>个人中心</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <script src="js/bootstrap.bundle.js"></script>
    <style>
        .container{
            margin-top: 20px;
        }
    </style>
</head>
<body>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url ="jdbc:mysql://localhost:3306/mxy";
    Connection connection = DriverManager.getConnection(url,"root","root");

    String sql ="select * from user where username =? and password = ?";
    //PreparedStatement ps =connection.prepareStatement(sql);
    //ps.setString(1,request.getParameter("username"));
   // ps.setString(2,request.getParameter("password"));
    //ResultSet rs =ps.executeQuery();
    //while (rs.next()){
      //  out.print(rs.getString("username")+"-"+rs.getString(3)+"<br>");
   // }
    if(session.getAttribute("username")==null){
        out.print("登录失败,将3秒之后跳转到登录页面");
        response.setHeader("refresh","3;url='login.jsp'");
    }
    out.print("欢迎来到个人主页");
    Class.forName("com.mysql.jdbc.Driver");
    String url="jdbc:mysql://localhost:3306/book";
    Connection connection=DriverManager.getConnection(url,"root","root");
    String sql="select * from user";
    PreparedStatement ps=connection.prepareStatement(sql);
    ResultSet rs=ps.executeQuery();
%>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <h3 style="text-align: center">欢迎来到个人主页！</h3>
            <table class="table table-striped">
                <thead>
                <th>ID</th>
                <th>用户名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>操作</th>
                </thead>
                <tbody>
                <%
                    while (rs.next()){
                        out.print("<tr>");
                        out.print(
                                "<td>"+rs.getString("id")
                                +"</td><td>"+rs.getString("用户名")
                                +"</td><td>"
                        );
                    }
                %>



</body>
</html>
